extends "res://scenes/enemies/enemy.gd"
func _ready():
	max_speed = max_speed / 1.2
	acceleration = max_speed / 0.2
	

# 此怪物只会左右移动，并且遇到障碍物会反转
func _physics_process(delta):
	if not is_on_floor():
		velocity.y += gravity * delta
	var was_on_wall = is_on_wall()
	
	move_and_slide()
	
	if !was_on_wall && is_on_wall():
		direction *= -1

func _process(delta):
	if is_death:
		velocity.x = 0
		return
		
	# 以起始速度到最大速度， 加速度为 acceleration
	velocity.x = move_toward(velocity.x, max_speed * direction, acceleration * delta)
	
	sprite.flip_h = velocity.x > 0
